<!--
 * @Descripttion: 异步选择器
 * @version: 1.0
 * @Author: sakuya
 * @Date: 2021年8月3日15:53:37
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-07-06 16:26:58
-->

<template>
  <skCheckBox v-model="value" :apiObj="url" :valueEqKey="valueEqKey" :params="params" type="width:100%" />
</template>

<script>
import skCheckBox from "./../skCheckBox";

export default {
  emits: ["checked", "update:modelValue"],
  name: "skDicCheckBox",
  props: {
    code: { type: String, default: () => "" },
    valueEqKey: { type: Boolean, default: false },
    modelValue: null,
  },
  components: { skCheckBox },
  watch: {
    modelValue() {

      let defaultv = this.modelValue;
      if (typeof defaultv == "string") {
        defaultv = defaultv.split(",");
      }
      else if (defaultv == null) {
        defaultv = [];
      }
      this.value = defaultv;
    },
    value() {
      this.$emit("checked", this.change);
      this.$emit("update:modelValue", this.value);
    },
    options() {
      this.valueChange();
    },
  },
  data() {

    let defaultv = this.modelValue;
    if (typeof defaultv == "string") {
      defaultv = defaultv.split(",");
    }
    else if (defaultv == null) {
      defaultv = [];
    }

    return {
      url: this.$API.system.dic.getDicData,
      params: { code: this.code },
      value: defaultv,
    };
  },
  methods: {

  },
};
</script>
